package com.example.x.dnuifood_929dx.controller;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.example.x.dnuifood_929dx.R;
import com.example.x.dnuifood_929dx.adapter.CommentAdapter;
import com.example.x.dnuifood_929dx.bean.CommentInfo;
import com.example.x.dnuifood_929dx.listener.onRetrofitListener;
import com.example.x.dnuifood_929dx.model.FoodModel;

import java.util.List;

/**
 * Created by X on 2018/12/4.
 */

public class MyCommentActivity extends  BaseActivity  implements onRetrofitListener<List<CommentInfo>> {
    private RecyclerView mycomment_rv;
    private ImageView mycomment_return;
    private CommentAdapter adapter;
    private FoodModel foodModel;

    @Override
    void initViews() {
        setLayout(R.layout.mycommentactivity);
        mycomment_return = (ImageView)findViewById(R.id.mycomment_return);
        mycomment_rv = (RecyclerView) findViewById(R.id.mycomment_rv);
        mycomment_rv.setLayoutManager(new LinearLayoutManager(MyCommentActivity.this));

    }

    @Override
    void initEvents() {
        mycomment_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish(); }
        });
    }

    @Override
    void initData() {
        foodModel=new FoodModel();
        foodModel.getAllCommentsByUser(getUser_id(),this);
    }



    @Override
    public void onSuccess(List<CommentInfo> object, int flag) {
        adapter = new CommentAdapter(MyCommentActivity.this, object, R.layout.shop_item6);
        mycomment_rv.setAdapter(adapter);
    }

    @Override
    public void onFailure(String msg) {

    }
}
